const Utils = require('../utils');

module.exports = () => {
  return (err, req, res, next) => {
    if (res.headersSent) {
      return next(err);
    }
    Utils.Logger.error(`m_err_error: ${err.stack}`);
    res.status(err.status || 500);
    res.send(err.message || 'Internal Error!');
  }
};